﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using KetBanBonPhuong;

public partial class Admin_UserControls_Login : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void LoginButton_Click(object sender, EventArgs e)
    {
        
    }
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        int rs = Admin.AdminLogin(Login1.UserName, Encrypt.MD5Encrypt(Login1.Password));
        if (rs == -1)
        {
            Login1.FailureText = "(*) Sai Email!";
            return;
        }
        else if (rs == 0)
        {
            Login1.FailureText = "(*) Sai mật khẩu!";
            return;
        }
        else if (rs == 1)
        {
            // thành công
            Session["AdminID"] = rs;
            Response.Redirect("AdminManagement.aspx");
        }
        Login1.FailureText = "(*) Lỗi khác!";
    }
}
